import myMixin from '../../../mixin/myMixin.js'
const FN = require('../../../utils/public');
import commonAPI from '../../../api/api'
var app = getApp();
Page({
  mixins: [myMixin],
  data: {
    evadingAudit: {},
    userInfo: {},
    initpage: true,
    classId: '',
    stuWXinfo: {}
  },

  onLoad: function (options) {
    this.getEAlistByNo();
  },

  // roleIds id=29代表运营管理专员
  saveTeacherInfo: function (e) {
    var that = this;
    let realname = this.generateRandomString(11);
    let organizationName = this.generateRandomString(11);
    let userName = this.generateRandomString(11);
    let params = {realname,organizationName,userName,userPwd:'123456'}
      const obj = { userinfo: { ...params,roleIds:[29] }, organizationName: params.organizationName }
      commonAPI.organizationSave(obj).then(res => {
        FN.Toast('提交成功！')
      })
  },

  generateRandomString(maxLength) {
    const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    const length = Math.floor(Math.random() * maxLength) + 1; // 确保长度至少为1，最大不超过maxLength
    let result = '';

    for (let i = 0; i < length; i++) {
        const randomIndex = Math.floor(Math.random() * characters.length);
        result += characters.charAt(randomIndex);
    }
debugger
    return result;
},

  // 复制功能
  copyInfo: function () {
    wx.setClipboardData({
      data: 'http://leshijiewx.com:8964',
      success: function (res) {
        FN.Toast('复制成功')
      }
    });
  },

  checkedData: function (frmData) {
    if (frmData.realname == "") {
      FN.Toast('姓名不能为空')
      return false;
    } else if (frmData.organizationName == "") {
      FN.Toast('平台不能为空')
      return false;
    } else if (frmData.userName.length != 11) {
      FN.Toast('手机号格式有误！')
      return false;
    } else if (frmData.userPwd == "") {
      FN.Toast('请设置后台密码！')
      return false;
    } else {
      return true;
    }
  },

  // 获取用户当前头像信息
  getEAlistByNo: function () {
    this.setData({
      evadingAudit: app.globalData.evadingAudit
    })
    console.log(app.globalData.wxUserInfo)
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  onShareAppMessage: function (res) {

  }

})